package com.ldu.exam.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Builder
@Table(name="t_class")
public class ClaModel 
{
	@Id
	@Column(length=32)
	@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "jpa-uuid")
	@GenericGenerator(name = "jpa-uuid",strategy = "uuid.hex")
	private String id;
	
	/**
	 * 班级名称
	 */
	@Column(name="classname")
	private String claName;
	
	/**
	 * 学生人数
	 */
	@Column(name="studentsnum")
	private int studentsNum;
	
	/**
	 * 备注
	 */
	private String summary;
	
	/**
	 * 状态(0启用1禁用)
	 */
	private String state;
	
	/**
	 * 创建人ID
	 */
	@OneToOne
	@JoinColumn(name="createdid")
	@JsonIgnoreProperties(value = {"cla","studentCla","pic"})
	private AccountModel created;
	
	/**
	 * 创建时间
	 */
	@CreationTimestamp
	private Timestamp creationDate ;
	
	/**
	 * 修改时间
	 */
	@UpdateTimestamp
	private Timestamp updateDate ;
	
	@ManyToOne
	@JoinColumn(name="manager_Id")
//	@JsonIgnoreProperties("cla")
	@JsonIgnoreProperties(value = {"cla","studentCla","pic","roles"})
	private AccountModel account;
	
	@ManyToOne
	@JoinColumn(name="examid")
	@JsonIgnoreProperties(value= {"created","ExamClas"})
	private ExamModel exam;
	
	@OneToMany(mappedBy="studentCla")
	@JsonIgnoreProperties(value = {"cla","studentCla","pic","roles"})
	private Set<AccountModel> studentAccounts ;
}
